<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<script src="./vue.js"></script>
<script src="./vue-router.js"></script>

<body>
  <div id="app">
    <button @click="goStart">跳!!</button>
    <router-view></router-view>
  </div>


  <script>
    let user = {
      template: `<h1>用户名: {{this.$route.params.name}}</h1>`
    }

    let router = new VueRouter({
      routes: [{
        path: "/user",
        name: "user",
        component: user
      }]
    })

    const vm = new Vue({
      el: "#app",
      router,
      methods: {
        goStart() {
          this.$router.push({
            name: "user",
            params: {
              name: "admin"
            }
          })
        }
      }
    })
  </script>
</body>

</html>